package com.clqteam.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.clqteam.service.OrderService;
import com.clqteam.serviceimpl.OrderServiceImpl;

import net.sf.json.JSONObject;

/**
 * 模糊查找订单控制层
 * @author ZHX
 *
 */
public class SearchOrderController extends HttpServlet{
	
	OrderService oSer = new OrderServiceImpl();

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doPost(req, resp);
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		req.setCharacterEncoding("UTF8");
		resp.setCharacterEncoding("UTF8");
		
		int page = Integer.parseInt(req.getParameter("page"));
		int rows = Integer.parseInt(req.getParameter("rows"));
		String key = req.getParameter("search");		
		
		JSONObject j = oSer.findInfoByKey(key, page, rows);
		
		PrintWriter pw = resp.getWriter();
		pw.write(j.toString());
		pw.flush();
		pw.close();
		
	}
	
}
